import request from '@/utils/axios';
import {UserPassword} from "@/api/module/userPassword";
import {UserRegistration} from "@/api/module/userRegistration";

interface IResponseType<P = {}> {
    code?: number;
    msg: string;
    data: P;
}

export const detail = (id : number)=>{
    return request<IResponseType>({
        url: '/user/getUserDetail',
        method: 'get',
        params: { id: id }
    });
}
export const sendEmail = (emailUrl : string)=>{
    return request<IResponseType>({
        url: '/user/sendEmail',
        method: 'get',
        params: { emailUrl: emailUrl }
    });
}
export const uploadPassword = (user : UserPassword)=>{
    return request<IResponseType>({
        url: '/user/uploadPassword',
        method: 'post',
        data: user
    });
}
export const update = (user : UserPassword)=>{
    return request<IResponseType>({
        url: '/user/update',
        method: 'post',
        data: user
    });
}
export const sendRegisEmail = (emailUrl : string)=>{
    return request<IResponseType>({
        url: '/user/sendRegisEmail',
        method: 'get',
        params: { emailUrl: emailUrl }
    });
}
export const register = (userDTO : UserRegistration)=>{
    return request<IResponseType>({
        url: '/user/register',
        method: 'post',
        data: userDTO
    });
}
export default { detail,sendEmail,uploadPassword,update,sendRegisEmail,register };